<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <div th:include="includeJs::bootstrap_js"></div>
    <div th:include="includeJs::layui_js"></div>
</head>
<body>
<div class="container-scroller d-flex">
    <div th:replace="includeJs::admin_leftNav"></div>

    <div class="container-fluid page-body-wrapper">
        <div th:replace="includeJs::admin_nav"></div>
        <table class="layui-hide" lay-filter="test" id="demo"></table>
        <script type="text/html" id="barDemo">
            <!--删除-->
            <button lay-event="del" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon"></i>删除</button>
        </script>
    </div>
</div>
</body>
<script>
    let layer;
    let table;
    layui.use(['table', 'layer'], function(){
        layer = layui.layer;
        table = layui.table;
        table.render({
            elem:'#demo',
            toolbar:'#toolbar',
            height:500,
            url:'/specimens/touziList',
            title:'放标详情',
            cols:[
                [
                    {type:'checkbox', fixed:'left'}
                    ,{field:'bid_id',title:'投资编号', width:100, fixed: 'left', unresize: true, sort: true}
                    ,{field:'money', title:'投资金额(元)', width:100,sort:true}
                    ,{field:'mark_name', title:'投资的项目名称', width:130}
                    ,{field:'nick_name', title:'投资人姓名',width:100}
                    ,{field:'investor_iph', title:'投资人号码',width:150}
                    ,{field:'Investment_time', title:'投资时间', width:200,templet:'<div>{{ layui.util.toDateString(d.Investment_time,"yyyy-MM-dd HH:mm:ss")}}</div>'}
                    ,{field:'recovery_time', title:'收回时间', width:200}
                    ,{field:'estimate_money', title:'预计收回金额', width:130}
                    ,{field:'types', title:'类型',templet:function (d) {
                        if (d.state == 1) {
                            return '活期'
                        }else if(d.state == 2){
                            return '定期'
                        } width:100}}
                    ,{field:'state', title:'状态', templet:function (d) {
                        if (d.state == 1) {
                            return '已通过'
                        }else if(d.state == 2){
                            return '已收回'
                        }width:110}}
                    ,{fixed: '', width:180, title:'操作', align:'center', toolbar: '#barDemo'}

                ]
            ],
            page: {limit:5,page:1,limits:[5,10,15],layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']}
            ,done: function(res, page, count){//审核时间
                $("[data-field='recovery_time']").children().each(function(){
                    let data = $(this).text();
                    if(data.length==29){
                        let auditTime = layui.util.toDateString(data, 'yyyy-MM-dd HH:mm:ss')
                        $(this).text(auditTime)
                    }
                })
            }
        });

        //行工具栏
        table.on('tool(test)', function(obj){
            var datas = obj.data;//获取当前行数据
            var event = obj.event;//获得lay-event 对应的值（编辑，删除）
             if(event=='del'){
                window.location.href="/specimens/DidDelete/"+datas.bidId
            }
        });
    })
</script>
</html>